package com.itheima.bakery.demos.web.model;

import com.fasterxml.jackson.annotation.JsonProperty;

import javax.persistence.*;
import java.sql.Timestamp;


@Entity
@Table(name = "Inventory")
public class Inventory {
    @Id
    @Column(nullable = false)
    private Integer productID;

    @Column(nullable = false,name="stock_quantity")
    private Integer stockQuantity;

    @Column(name="reorder_Level")
    private Integer reorderLevel;

    @Column(name = "last_stock_update", updatable = false)
    private Timestamp lastStockUpdate;


    @PrePersist
    protected void onCreate() {
        lastStockUpdate = new Timestamp(System.currentTimeMillis());
    }

    public Inventory() {
    }
    public Inventory(Integer productID, Integer stockQuantity, Integer reorderLevel, Timestamp lastStockUpdate) {
        this.productID = productID;
        this.stockQuantity = stockQuantity;
        this.reorderLevel = reorderLevel;
        this.lastStockUpdate = lastStockUpdate;
    }
    // Getters and Setters
    public Integer getProductID() {
        return productID;
    }
    public void setProductID(Integer productID) {
        this.productID = productID;
    }
    public Integer getStockQuantity() {
        return stockQuantity;
    }
    public void setStockQuantity(Integer stockQuantity) {
        this.stockQuantity = stockQuantity;
    }
    public Integer getReorderLevel() {
        return reorderLevel;
    }
    public void setReorderLevel(Integer reorderLevel) {
        this.reorderLevel = reorderLevel;
    }
    public Timestamp getLastStockUpdate() {
        return lastStockUpdate;
    }
    public void setLastStockUpdate(Timestamp lastStockUpdate) {
        this.lastStockUpdate = lastStockUpdate;
    }

}